#include <stdio.h>
#include <stdint.h>
#include <string.h>

int a[81][81]; 
__int128  g_sum[81][81]; 
char      g_flag[81][81];

int print_uint128(__int128 n) 
{
  if (n == 0)  return printf("0\n");

  char str[40] = {0}; // log10(1 << 128) + '\0'
  char *s = str + sizeof(str) - 1; // start at the end
  while (n != 0) {
    if (s == str) return -1; // never happens

    *--s = "0123456789"[n % 10]; // save last digit
    n /= 10;                     // drop it
  }
  return printf("%s\n", s);
}

__int128 sum_line(int order, int line, int left_i, int right_i)
{
	__int128 sum, sum_left, sum_right; 

	if (left_i==right_i) {
		return ((uint64_t)a[line][left_i])*(((__int128)1)<<order); 
	}
	if (g_flag[order][left_i]) {
		return g_sum[order][left_i]; 
	}
	sum_left = ((__int128)a[line][left_i])*(((__int128)1)<<order) + sum_line(order+1, line, left_i+1, right_i); 
	sum_right = ((__int128)a[line][right_i])*(((__int128)1)<<order) + sum_line(order+1, line, left_i, right_i-1); 
	sum = sum_left > sum_right ? sum_left : sum_right;
	g_flag[order][left_i] = 1; 
	g_sum[order][left_i] = sum; 
	printf("g_sum[%d][%d] = ", order, left_i); 
	print_uint128(sum); 
	return sum;
}


int main()
{
	__int128	sum = 0;
	int 		i, j, m, n;
	
	scanf("%d %d", &n, &m); 
	for (i=1; i<=n; i++) {
		for (j=1; j<=m; j++) {
			scanf("%d", &a[i][j]);
		}
	}

	for (i=1; i<=n; i++) {
		memset((char *)g_flag, 0, sizeof(g_flag));
		sum += sum_line(1, i, 1, m); 
		printf("i=%d, sum=", i); 
		print_uint128(sum); 
	}
	print_uint128(sum); 
	return 0;
}

//linux  uint64_t --> %llu,  __int128 --> %jd
//mingw  uint64_t --> %I64u  

